<!DOCTYPE html>
<html>
 <head> 
  <meta charset="utf-8" /> 
  <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> 
  <title>Jeesuite-统一运行管理后台 - 设置安全ip</title> 
  <link rel="stylesheet" href="webjars/plugins/layui/css/layui.css" media="all" /> 
  <link rel="stylesheet" href="webjars/css/login.css" /> 
 </head> 
 <body>
  <br><br>  
  <div style="width:400px;margin-left: 30px;"> 
    <button class="layui-btn" onclick="updateIpAddr();">更新IP</button>
  </div> 
  <script type="text/javascript" src="./webjars/plugins/layui/layui.js"></script> 
  <script type="text/javascript" src="./webjars/js/common.js?v20170728"></script> 
  <script>
  function updateIpAddr(){
	  layer.prompt({title: '输入操作确认码，并确认', formType: 1}, function(authcode, index){
		  layui.jquery.ajax({
				dataType:"json",
			    type: "POST",
		        url: './auth/update_safe_ipaddr?authcode='+authcode,
		        contentType: "application/json",
				complete: function(){layer.close(index);},
				success: function(data){
			        if(data.code==200){
			        	alert("当前允许操作IP:"+data.data);
			        	setTimeout(function(){window.location.href = './admin.html';},500);
			        }else if(data.code==403){
			        	 setTimeout(function(){window.location.href = './login.html';},500);
			        }else{
			        	  layer.msg(data.msg || '更新失败', {
								icon: 5
						  });
			          }
			        },
				error: function(xhr, type){
					layer.msg('系统错误', {
						icon: 5
					});
				}
			});
		});
  }
 </script>  
 </body>
</html>